import java.util.Scanner;
import java.util.Stack;

public class postfixExpression {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while (scan.hasNextLine()) {
            int num = Integer.parseInt(scan.nextLine());
            String[] in = scan.next().split(" ");
            Stack<Integer> stack = new Stack<>();
            for (int i = 0; i < num; i++) {
                String str = in[i];
                int res = 0;
                if (str.equals("*")) {
                    int num1 = stack.pop();
                    int num2 = stack.pop();
                    res = num1 * num2;
                    stack.push(res);
                } else if (str.equals("/")) {
                    int num1 = stack.pop();
                    int num2 = stack.pop();
                    res = num2 / num1;
                    stack.push(res);
                } else if (str.equals("+")) {
                    int num1 = stack.pop();
                    int num2 = stack.pop();
                    res = num1 + num2;
                    stack.push(res);
                } else if (str.equals("-")) {
                    int num1 = stack.pop();
                    int num2 = stack.pop();
                    res = num2 - num1;
                    stack.push(res);
                } else {
                    stack.push(Integer.parseInt(str));
                }
            }
            System.out.println(stack.pop());
        }
    }
}
